using System;
using System.Collections.Generic;
using System.Text;

namespace Xivo.Shared {
  public abstract class RadioBase : IXivoPlugin {
    /// <summary>
    /// Fired when the radio is turned on or off
    /// </summary>
    public abstract event Delegates.IntEvent onPowerChange;
    /// <summary>
    /// Fired when the current channel is changed
    /// </summary>
    public abstract event Delegates.IntEvent onChannelChange;
    /// <summary>
    /// Fired when the radio reports mute turned on or off.
    /// </summary>
    public abstract event Delegates.IntEvent onMuteChange;
    /// <summary>
    /// Fired when the current channel's information is updated.
    /// </summary>
    public abstract event Delegates.InfoEvent onChannelInfoChange;
    /// <summary>
    /// Fired when ANY channel's information is updated.
    /// </summary>
    public abstract event Delegates.InfoEvent onChannelInfoReceived;
    /// <summary>
    /// Returns radio ID or serial number.
    /// </summary>
    public abstract event Delegates.StringEvent onRadioIDReceived;
    /// <summary>
    /// Info about signal strength. For multi-antenna systems, such as XM,
    /// this event will fire once for each signal. 
    /// </summary>
    public abstract event Delegates.SignalEvent onSignalDataReceived;

    /// <summary>
    /// This is the type of radio that the object is looking for.
    /// Currently, we only support XM receivers, but I'd like to expand that
    /// in the future.
    /// </summary>
    public abstract string RadioType {
      get;
    }

    /// <summary>
    /// This list should contain all the channels that the attached radio supports.
    /// When supporting multiple radios, each should have its own list.
    /// </summary>
    public ChannelList channels = new ChannelList();

    /// <summary>
    /// Check whether the radio is on or off.
    /// Turn the radio on or off.
    /// </summary>
    public abstract int PowerState {
      get;
      set;
    }

    /// <summary>
    /// Checks the current channel.
    /// Tune the radio to a desired channel.
    /// </summary>
    public abstract int CurrentChannel {
      get;
      set;
    }

    /// <summary>
    /// 1 if radio is muted
    /// 0 if radio is not muted
    /// Set the value to mute/unmute the radio
    /// </summary>
    public abstract int MuteState {
      get;
      set;
    }

    /// <summary>
    /// This sets whether we WANT the radio on or off. When any command is sent to the radio
    /// it may return a "power is off" response. When, and only when, that response is received
    /// and this value is 1, the driver will try to turn the radio on.
    /// This has no effect when the radio is already on. 
    /// This cannot be used to turn the radio off.
    /// </summary>
    public abstract int DesiredPowerState {
      get;
      set;
    }

    void IXivoPlugin.Init() {
    }
    void IXivoPlugin.Start() {
    }
    void IXivoPlugin.ShutDown() {
    }

    public abstract string PortName {
      get;
      set;
    }

    public abstract string RadioID {
      get;
    }

    public abstract void requestSignalData();
    public abstract bool Busy {
      get;
    }

    public abstract void EnqueueChannelInfoRequest(ChannelInfo info);
    public abstract void ServiceChannelInfoQueue();
    public abstract void requestAllChannelInfo();
  }
}
